﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFrom2
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
  
        private void button4_Click(object sender, EventArgs e)
        {
            var name = this.textName.Text;
            var pwd = this.textpassword.Text;
            var pwdTry = this.textretpassword.Text;
            var conString = string.Format("select * from Articles");
            var con = Dbhelper.GetDataTable(conString);
            bool hasName = !string.IsNullOrEmpty(name);
            bool hasPwd = !string.IsNullOrEmpty(pwd);
            bool equal = pwd == pwdTry;

            if (hasName && hasPwd && equal)
            {
                var register = string.Format("insert into Articles values('{0}','{1}')", name, pwd);
                var res = Dbhelper.AddOrEdiOrdeletetSave(register);
                MessageBox.Show("注册成功");
                this.Close();
            }
            else
            {
                MessageBox.Show("注册失败");
            }
        }








    }
    
}
